﻿@namespace Bit.BlazorUI
@inherits BitComponentBase

@if (IsOpen)
{
    <div @ref="RootElement" @attributes="HtmlAttributes.Concat(ModalParameters.HtmlAttributes)"
         id="@_Id"
         style="@StyleBuilder.Value"
         class="@ClassBuilder.Value"
         dir="@ModalParameters.Dir?.ToString().ToLower()"
         aria-labelledby="@ModalParameters.TitleAriaId"
         aria-describedby="@ModalParameters.SubtitleAriaId"
         aria-modal="@((ModalParameters.Modeless is false).ToString().ToLower())"
         role="@GetRole()">
        @if (ModalParameters.Modeless is false)
        {
            <div @onclick="HandleOnOverlayClick"
                 aria-hidden="true"
                 style="@Styles?.Overlay @ModalParameters.Styles?.Overlay"
                 class="bit-mdl-ovl @Classes?.Overlay @ModalParameters.Classes?.Overlay" />
        }
        <div id="@_containerId"
             style="@($"{Styles?.Content} {ModalParameters.Styles?.Content}".Trim())"
             class="@($"bit-mdl-ctn {Classes?.Content} {ModalParameters.Classes?.Content}".Trim())">
            @ChildContent
        </div>
    </div>
}
